import { JSDOM } from 'jsdom';

if (!Object.prototype.hasOwnProperty.call(global, 'document')) {
    const window = new JSDOM('').window;

    global.document = new window.DOMParser().parseFromString(
        `<html>
            <head>
                <script src="simulator" type="script"></script>
            </head>
            <body></body>
        </html>`,

        'text/html'
    );

    [
        'HTMLElement',
        'HTMLHeadElement',
        'HTMLBodyElement',
        'HTMLScriptElement',

        'NodeList',
    ].forEach(key => global[key] = window[key]);
}
